/**
  ******************************************************************************
  * @file    bs32f1xx_ll_bus.h
  * @author  MCU Application Team
  * @brief   Header file of BUS LL module.
  ******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef BS32F1xx_LL_BUS_H
#define BS32F1xx_LL_BUS_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "bs32f1xx.h"
/** @addtogroup BS32F1xx_LL_Driver
  * @{
  */

#if defined(RCC)
/** @defgroup BUS_LL BUS
  * @{
  */


/* Exported constants --------------------------------------------------------*/
/** @defgroup BUS_LL_Exported_Constants BUS Exported Constants
  * @{
  */

/** @defgroup BUS_LL_EC_AHB_PERIPH AHB PERIPH
  * @{
  */
#define LL_AHB_PERIPH_ALL            0xFFFFFFFFU
#define LL_AHB_PERIPH_DMA1           RCC_AHBENR_DMA1EN
#define LL_AHB_PERIPH_CRC            RCC_AHBENR_CRCEN
#define LL_AHB_PERIPH_SPI1           RCC_AHBENR_SPI1EN
#define LL_AHB_PERIPH_SPI2           RCC_AHBENR_SPI2EN
#define LL_AHB_PERIPH_CAN1           RCC_AHBENR_CAN1EN
/**
  * @}
  */
  
/** @defgroup BUS_LL_EC_APB1_PERIPH  APB1 PERIPH
  * @{
  */
#define LL_APB1_PERIPH_ALL            0xFFFFFFFFU
#define LL_APB1_PERIPH_UART1          RCC_APBENR1_UART1EN
#define LL_APB1_PERIPH_UART2          RCC_APBENR1_UART2EN
#define LL_APB1_PERIPH_UART3          RCC_APBENR1_UART3EN
#define LL_APB1_PERIPH_I2C1           RCC_APBENR1_I2C1EN
#define LL_APB1_PERIPH_I2C2           RCC_APBENR1_I2C2EN
#define LL_APB1_PERIPH_TIM1           RCC_APBENR1_TIM1EN
#define LL_APB1_PERIPH_TIM3           RCC_APBENR1_TIM3EN
#define LL_APB1_PERIPH_TIM4           RCC_APBENR1_TIM4EN
#define LL_APB1_PERIPH_TIM2           RCC_APBENR1_TIM2EN
#define LL_APB1_PERIPH_WWDG           RCC_APBENR1_WWDGEN
#define LL_APB1_PERIPH_IWDG           RCC_APBENR1_IWDGEN
#define LL_APB1_PERIPH_ADC1           RCC_APBENR1_ADC1EN
#define LL_APB1_PERIPH_ADC2           RCC_APBENR1_ADC2EN
#define LL_APB1_PERIPH_TIM6           RCC_APBENR1_TIM6EN
#define LL_APB1_PERIPH_RTC            RCC_APBENR1_RTCEN
/**
  * @}
  */
  
/** @defgroup BUS_LL_EC_IOP_GRP1_PERIPH  IOP GRP1 PERIPH
  * @{
  */
#define LL_IOP_PERIPH_ALL             0xFFFFFFFFU
#define LL_IOP_PERIPH_GPIOA           RCC_IOPENR_GPIOAEN
#define LL_IOP_PERIPH_GPIOB           RCC_IOPENR_GPIOBEN
#define LL_IOP_PERIPH_GPIOC           RCC_IOPENR_GPIOCEN
#define LL_IOP_PERIPH_GPIOD           RCC_IOPENR_GPIODEN
/**
  * @}
  */
  
/**
  * @}
  */
  
/* Exported functions --------------------------------------------------------*/
/** @defgroup BUS_LL_Exported_Functions BUS Exported Functions
  * @{
  */

/**
  * @brief  Enable AHB peripherals clock.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_AHB_PERIPH_DMA1 
  *         @arg @ref LL_AHB_PERIPH_CRC
  *         @arg @ref LL_AHB_PERIPH_SPI1
  *         @arg @ref LL_AHB_PERIPH_SPI2
  *         @arg @ref LL_AHB_PERIPH_CAN1 
  * @retval None
*/
__STATIC_INLINE void LL_AHB_EnableClock(uint32_t Periphs)
{
  __IO uint32_t tmpreg;
  SET_BIT(RCC->AHBENR, Periphs);
  /* Delay after an RCC peripheral clock enabling */
  tmpreg = READ_BIT(RCC->AHBENR, Periphs);
  (void)tmpreg;
}

/**
  * @brief  Check if AHB peripheral clock is enabled or not
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_AHB_PERIPH_DMA1 
  *         @arg @ref LL_AHB_PERIPH_CRC
  *         @arg @ref LL_AHB_PERIPH_SPI1
  *         @arg @ref LL_AHB_PERIPH_SPI2
  *         @arg @ref LL_AHB_PERIPH_CAN1 
  * @retval State of Periphs (1 or 0).
*/
__STATIC_INLINE uint32_t LL_AHB_IsEnabledClock(uint32_t Periphs)
{
  return ((READ_BIT(RCC->AHBENR, Periphs) == Periphs) ? 1UL : 0UL);
}

/**
  * @brief  Disable AHB peripherals clock.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_AHB_PERIPH_DMA1 
  *         @arg @ref LL_AHB_PERIPH_CRC
  *         @arg @ref LL_AHB_PERIPH_SPI1
  *         @arg @ref LL_AHB_PERIPH_SPI2
  *         @arg @ref LL_AHB_PERIPH_CAN1 
  * @retval None
*/
__STATIC_INLINE void LL_AHB_DisableClock(uint32_t Periphs)
{
  CLEAR_BIT(RCC->AHBENR, Periphs);
}

/**
  * @brief  Force AHB peripherals reset.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_AHB_PERIPH_ALL
  *         @arg @ref LL_AHB_PERIPH_DMA1 
  *         @arg @ref LL_AHB_PERIPH_CRC
  *         @arg @ref LL_AHB_PERIPH_SPI1
  *         @arg @ref LL_AHB_PERIPH_SPI2
  *         @arg @ref LL_AHB_PERIPH_CAN1 
  * @retval None
*/
__STATIC_INLINE void LL_AHB_ForceReset(uint32_t Periphs)
{
  SET_BIT(RCC->AHBRSTR, Periphs);
}

/**
  * @brief  Release AHB peripherals reset.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_AHB_PERIPH_ALL
  *         @arg @ref LL_AHB_PERIPH_DMA1 
  *         @arg @ref LL_AHB_PERIPH_CRC 
  *         @arg @ref LL_AHB_PERIPH_SPI1
  *         @arg @ref LL_AHB_PERIPH_SPI2
  *         @arg @ref LL_AHB_PERIPH_CAN1 
  * @retval None
*/
__STATIC_INLINE void LL_AHB_ReleaseReset(uint32_t Periphs)
{
  CLEAR_BIT(RCC->AHBRSTR, Periphs);
}

/**
  * @brief  Enable APB peripherals clock.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_APB1_PERIPH_UART1 
  *         @arg @ref LL_APB1_PERIPH_UART2
  *         @arg @ref LL_APB1_PERIPH_UART3
  *         @arg @ref LL_APB1_PERIPH_I2C1  
  *         @arg @ref LL_APB1_PERIPH_I2C2  
  *         @arg @ref LL_APB1_PERIPH_TIM1  
  *         @arg @ref LL_APB1_PERIPH_TIM3  
  *         @arg @ref LL_APB1_PERIPH_TIM4 
  *         @arg @ref LL_APB1_PERIPH_TIM2 
  *         @arg @ref LL_APB1_PERIPH_WWDG  
  *         @arg @ref LL_APB1_PERIPH_IWDG  
  *         @arg @ref LL_APB1_PERIPH_ADC1
  *         @arg @ref LL_APB1_PERIPH_ADC2
  *         @arg @ref LL_APB1_PERIPH_TIM6  
  *         @arg @ref LL_APB1_PERIPH_RTC
  * @retval None
*/
__STATIC_INLINE void LL_APB1_EnableClock(uint32_t Periphs)
{
  __IO uint32_t tmpreg;
  SET_BIT(RCC->APBENR1, Periphs);
  /* Delay after an RCC peripheral clock enabling */
  tmpreg = READ_BIT(RCC->APBENR1, Periphs);
  (void)tmpreg;
}

/**
  * @brief  Check if APB peripheral clock is enabled or not
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_APB1_PERIPH_UART1 
  *         @arg @ref LL_APB1_PERIPH_UART2
  *         @arg @ref LL_APB1_PERIPH_UART3
  *         @arg @ref LL_APB1_PERIPH_I2C1  
  *         @arg @ref LL_APB1_PERIPH_I2C2  
  *         @arg @ref LL_APB1_PERIPH_TIM1  
  *         @arg @ref LL_APB1_PERIPH_TIM3  
  *         @arg @ref LL_APB1_PERIPH_TIM4 
  *         @arg @ref LL_APB1_PERIPH_TIM2 
  *         @arg @ref LL_APB1_PERIPH_WWDG  
  *         @arg @ref LL_APB1_PERIPH_IWDG  
  *         @arg @ref LL_APB1_PERIPH_ADC1
  *         @arg @ref LL_APB1_PERIPH_ADC2
  *         @arg @ref LL_APB1_PERIPH_TIM6  
  *         @arg @ref LL_APB1_PERIPH_RTC  
  * @retval State of Periphs (1 or 0).
*/
__STATIC_INLINE uint32_t LL_APB1_IsEnabledClock(uint32_t Periphs)
{
  return ((READ_BIT(RCC->APBENR1, Periphs) == (Periphs)) ? 1UL : 0UL);
}

/**
  * @brief  Disable APB1 peripherals clock.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_APB1_PERIPH_UART1 
  *         @arg @ref LL_APB1_PERIPH_UART2
  *         @arg @ref LL_APB1_PERIPH_UART3
  *         @arg @ref LL_APB1_PERIPH_I2C1  
  *         @arg @ref LL_APB1_PERIPH_I2C2  
  *         @arg @ref LL_APB1_PERIPH_TIM1  
  *         @arg @ref LL_APB1_PERIPH_TIM3  
  *         @arg @ref LL_APB1_PERIPH_TIM4 
  *         @arg @ref LL_APB1_PERIPH_TIM2 
  *         @arg @ref LL_APB1_PERIPH_WWDG  
  *         @arg @ref LL_APB1_PERIPH_IWDG  
  *         @arg @ref LL_APB1_PERIPH_ADC1
  *         @arg @ref LL_APB1_PERIPH_ADC2
  *         @arg @ref LL_APB1_PERIPH_TIM6  
  *         @arg @ref LL_APB1_PERIPH_RTC
  * @retval None
*/
__STATIC_INLINE void LL_APB1_DisableClock(uint32_t Periphs)
{
  CLEAR_BIT(RCC->APBENR1, Periphs);
}

/**
  * @brief  Force APB1 peripherals reset.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_APB1_PERIPH_ALL
  *         @arg @ref LL_APB1_PERIPH_UART1 
  *         @arg @ref LL_APB1_PERIPH_UART2
  *         @arg @ref LL_APB1_PERIPH_UART3
  *         @arg @ref LL_APB1_PERIPH_I2C1  
  *         @arg @ref LL_APB1_PERIPH_I2C2  
  *         @arg @ref LL_APB1_PERIPH_TIM1  
  *         @arg @ref LL_APB1_PERIPH_TIM3  
  *         @arg @ref LL_APB1_PERIPH_TIM4 
  *         @arg @ref LL_APB1_PERIPH_TIM2 
  *         @arg @ref LL_APB1_PERIPH_WWDG  
  *         @arg @ref LL_APB1_PERIPH_IWDG  
  *         @arg @ref LL_APB1_PERIPH_ADC1
  *         @arg @ref LL_APB1_PERIPH_ADC2
  *         @arg @ref LL_APB1_PERIPH_TIM6  
  *         @arg @ref LL_APB1_PERIPH_RTC
  * @retval None
*/
__STATIC_INLINE void LL_APB1_ForceReset(uint32_t Periphs)
{
  SET_BIT(RCC->APBRSTR1, Periphs);
}

/**
  * @brief  Release APB peripherals reset.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_APB1_PERIPH_ALL  
  *         @arg @ref LL_APB1_PERIPH_UART1 
  *         @arg @ref LL_APB1_PERIPH_UART2
  *         @arg @ref LL_APB1_PERIPH_UART3
  *         @arg @ref LL_APB1_PERIPH_I2C1  
  *         @arg @ref LL_APB1_PERIPH_I2C2  
  *         @arg @ref LL_APB1_PERIPH_TIM1  
  *         @arg @ref LL_APB1_PERIPH_TIM3  
  *         @arg @ref LL_APB1_PERIPH_TIM4 
  *         @arg @ref LL_APB1_PERIPH_TIM2 
  *         @arg @ref LL_APB1_PERIPH_WWDG  
  *         @arg @ref LL_APB1_PERIPH_IWDG  
  *         @arg @ref LL_APB1_PERIPH_ADC1
  *         @arg @ref LL_APB1_PERIPH_ADC2
  *         @arg @ref LL_APB1_PERIPH_TIM6  
  *         @arg @ref LL_APB1_PERIPH_RTC
  * @retval None
*/
__STATIC_INLINE void LL_APB1_ReleaseReset(uint32_t Periphs)
{
  CLEAR_BIT(RCC->APBRSTR1, Periphs);
}

/**
  * @brief  Enable IOP peripherals clock.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_IOP_PERIPH_GPIOA
  *         @arg @ref LL_IOP_PERIPH_GPIOB
  *         @arg @ref LL_IOP_PERIPH_GPIOC
  *         @arg @ref LL_IOP_PERIPH_GPIOD
  * @retval None
*/
__STATIC_INLINE void LL_IOP_EnableClock(uint32_t Periphs)
{
  __IO uint32_t tmpreg;
  SET_BIT(RCC->IOPENR, Periphs);
  /* Delay after an RCC peripheral clock enabling */
  tmpreg = READ_BIT(RCC->IOPENR, Periphs);
  (void)tmpreg;
}

/**
  * @brief  Check if IOP peripheral clock is enabled or not
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_IOP_PERIPH_GPIOA
  *         @arg @ref LL_IOP_PERIPH_GPIOB
  *         @arg @ref LL_IOP_PERIPH_GPIOC
  *         @arg @ref LL_IOP_PERIPH_GPIOD
  * @retval State of Periphs (1 or 0).
*/
__STATIC_INLINE uint32_t LL_IOP_IsEnabledClock(uint32_t Periphs)
{
  return ((READ_BIT(RCC->IOPENR, Periphs) == Periphs) ? 1UL : 0UL);
}

/**
  * @brief  Disable IOP peripherals clock.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_IOP_PERIPH_GPIOA
  *         @arg @ref LL_IOP_PERIPH_GPIOB
  *         @arg @ref LL_IOP_PERIPH_GPIOC
  *         @arg @ref LL_IOP_PERIPH_GPIOD
  * @retval None
*/
__STATIC_INLINE void LL_IOP_DisableClock(uint32_t Periphs)
{
  CLEAR_BIT(RCC->IOPENR, Periphs);
}

/**
  * @brief  Disable IOP peripherals clock.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_IOP_PERIPH_ALL
  *         @arg @ref LL_IOP_PERIPH_GPIOA
  *         @arg @ref LL_IOP_PERIPH_GPIOB
  *         @arg @ref LL_IOP_PERIPH_GPIOC
  *         @arg @ref LL_IOP_PERIPH_GPIOD
  * @retval None
*/
__STATIC_INLINE void LL_IOP_ForceReset(uint32_t Periphs)
{
  SET_BIT(RCC->IOPRSTR, Periphs);
}

/**
  * @brief  Release IOP peripherals reset.
  * @param  Periphs This parameter can be a combination of the following values:
  *         @arg @ref LL_IOP_PERIPH_ALL
  *         @arg @ref LL_IOP_PERIPH_GPIOA
  *         @arg @ref LL_IOP_PERIPH_GPIOB
  *         @arg @ref LL_IOP_PERIPH_GPIOC
  *         @arg @ref LL_IOP_PERIPH_GPIOD
  * @retval None
*/
__STATIC_INLINE void LL_IOP_ReleaseReset(uint32_t Periphs)
{
  CLEAR_BIT(RCC->IOPRSTR, Periphs);
}
/**
  * @}
  */
  
/**
  * @}
  */

#endif /* defined(RCC) */
/**
  * @}
  */
  

#ifdef __cplusplus
}
#endif

#endif /* BS32F1xx_LL_BUS_H */

/************************ (C) COPYRIGHT BSMicroelectronics *****END OF FILE****/
